<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
%>
<script type="text/javascript" src="<%=path%>/projectjs/ImageFileUpload.js"></script>
<script src="<%=path %>/projectjs/cardEntity.js" type="text/javascript"></script>
<script type="text/javascript">
	function addEntity(obj){
		if (!iu1.validate()) {
			alert("您还有像素为：【"+iu1.need_add_pic_pixel.join(",")+"】的未激活图片要添加，请添加图片！");
			iu1.openAddImgFrame();
			return false;
		}
		if (!iu2.validate()) {
			alert("您还有像素为：【"+iu2.need_add_pic_pixel.join(",")+"】的已激活图片要添加，请添加图片！");
			iu2.openAddImgFrame();
			return false;
		}
		if (!checkDate("inp_dateFrom","inp_dateTo"))return false;
		if(!checkCurrentDate("inp_dateFrom"))return false;
		if($("#add_cardEntity_cardLever").val()=="-1"){
			alertMsg.error("请选择会员卡级别！");
			return false;
		}
		if($("#add_cardEntity_cardAgio").val()=="-1"){
			alertMsg.error("请选择基础折扣！");
			return false;
		}
		if($("#sel_cardEntityAdd_applyway").val()=="-1"){
			alertMsg.error("请选择申请方式！");
			return false;
		}
		var limitAmount = $("#inp_cardEntityAdd_limitAmount").val();
		if (limitAmount != "") {
			limitAmount=checkNum(limitAmount);
			if(limitAmount==""){
				alertMsg.error("您输入的数量有误！");
				return false;
			}
			$("#inp_cardEntityAdd_limitAmount").val(limitAmount);
		}
		selectCardEntityFileds();
		return validateCallback(obj, navTabAjaxDone);
	}
	function selectCardEntityFileds(){
		var fileds = "";
		$('input[type="checkbox"][name="fileds"]:checked').each(
				function(){ 
		     		fileds += $(this).val() + ","; 
				}
	           );
       $("#postFileds").val(fileds);
	}
</script>
<script src="<%=path %>/js/dwz.tab.js" type="text/javascript"></script>
<div class="pageContent">
	<div class="tabs" currentIndex="0" eventType="click">
		<div class="tabsHeader">
			<div class="tabsHeaderContent">
				<ul>
					<li><a href="javascript:;"><span>基本信息</span></a></li>
					<li><a href="javascript:;"><span>初始计次</span></a></li>
					<li><a href="javascript:;"><span>充值规则</span></a></li>
					<li><a href="javascript:;"><span>升级规则</span></a></li>
					<li><a href="javascript:;"><span>初始服务</span></a></li>
				</ul>
			</div>
		</div>
		<div class="tabsContent" style="height:502px;">
			<div class="pageContent">
		<form method="post" action="<%=path %>/cardEntity/saveCardEntity.action"  class="pageForm required-validate" onsubmit="return addEntity(this);">
			<div class="pageFormContent" layoutH="90">
				<input type="hidden" name="cardEntityVO.customerId" value="<s:property value="cardEntityVO.customerId" />"/>
				<p>
					<label>会员卡方案编码：</label>
					<input name="cardEntityVO.schemeCode" value="<s:property value="cardEntityVO.schemeCode" />" class="required" type="text" size="30" readonly="readonly"/>
				</p>
				<p>
					<label>商户编码：</label>
					<input name="cardEntityVO.merchantCode" value="${SESSION_USER.customer==null?'':(SESSION_USER.customer.code)}" class="required" type="text" readonly="readonly" size="30" />
					<c:if test="${SESSION_USER.customer==null}">
					<a class="btnLook" href="<%=path%>/customer/listCustomer.action?searchType=cardEntity&lookUpPre=add" lookupGroup="cardEntityVO">选择</a>
					</c:if>
				</p>
				<p>
					<label>会员卡名称：</label>
					<input name="cardEntityVO.cardName" class="required" type="text" size="30" />
				</p>
				<p>
					<label>商户名：</label>
					<input name="cardEntityVO.merchantNamer"  value="${SESSION_USER.customer==null?'':(SESSION_USER.customer.name)}" class="required" type="text" readonly="readonly" size="30"/>
				</p>
				<p>
					<label>会员卡级别：</label>
					<select name="cardEntityVO.cardLever" id="add_cardEntity_cardLever">
							<option value="-1">请选择</option>
                            <c:forEach var="item" items="${cardLevelList}">
                                <option value="${item.id}" ${cardEntityVO.cardLever eq item.id?"selected":"" }>${item.levelName}</option>
                            </c:forEach>
	              	</select>
				</p>
				<p>
					<label>有效期开始：</label>
					<input id="inp_dateFrom" name="cardEntityVO.expiryDateFrom" value="<s:property value="cardEntityVO.expiryDateFrom" />" readonly="true" class="date required" type="text" size="20" /><a class="inputDateButton" href="javascript:;">选择</a>
				</p>
				<p>
					<label>有效期截止：</label>
					<input id="inp_dateTo" name="cardEntityVO.expiryDateTo" value="<s:property value="cardEntityVO.expiryDateTo" />" readonly="true" class="date required" type="text" size="20" /><a class="inputDateButton" href="javascript:;">选择</a>
				</p>
				<p>
					<label>申请方式：</label>
					<select id="sel_cardEntityAdd_applyway" name="cardEntityVO.applyWay" class="combox">
						<option value="-1">请选择</option>
						<option value="1">商家自发</option>
						<option value="2">商家自发+自主申请</option>
						<option value="3">自主申请</option>
              		</select>
				</p>
				<p>
					<label>基础折扣：</label>
					<select name="cardEntityVO.baseDiscount" id="add_cardEntity_cardAgio">
							<option value="-1">请选择</option>
                            <c:forEach var="item" items="${cardAgioList}">
                                <option value="${item.id}" ${cardEntityVO.baseDiscount eq item.id?"selected":"" }>${item.name}</option>
                            </c:forEach>
	              	</select>
				</p>
				<p>
					<label>数量限制：</label>
					<input id="inp_cardEntityAdd_limitAmount" name="cardEntityVO.limitAmount" value="<s:property value="cardEntityVO.limitAmount" />" class="required" type="text" size="15" alt="请输入数量限制"/>
				</p>
				<p>
					<label>是否推荐：</label>
					<s:select name="cardEntityVO.isRecommend"
							list="%{#{0:'否',1:'是'}}" listKey="key" listValue="value" ></s:select>
				</p>
				<p>
					<label>是否热门：</label>
					<s:select name="cardEntityVO.isHot"
							list="%{#{0:'否',1:'是'}}" listKey="key" listValue="value" ></s:select>
				</p>
				<div class="divider" style="border: 0"></div>
					<dl class="nowrap">
						<dt>折扣描述：</dt>
						<dd>
						<textarea class="textInput required" rows="2" cols="80" name="cardEntityVO.agioInfo" style="align:left; width: 510px; height: 80px;"><s:property value="cardEntityVO.agioInfo" /></textarea>
						</dd>
					</dl>
				<div class="divider" style="border: 0"></div>
					<dl class="nowrap">
						<dt>会员福利：</dt>
						<dd>
						<textarea class="textInput required" rows="2" cols="80" name="cardEntityVO.welfare" style="align:left; width: 510px; height: 80px;"><s:property value="cardEntityVO.welfare" /></textarea>
						</dd>
					</dl>
				<div class="divider" style="border: 0"></div>
					<dl class="nowrap">
						<dt>使用须知：</dt>
						<dd>
						<textarea class="textInput required" rows="2" cols="80" name="cardEntityVO.useNotes" style="align:left; width: 510px; height: 80px;"><s:property value="cardEntityVO.useNotes" /></textarea>
						</dd>
					</dl>
					<label>可选录入项：</label>
					<input type="hidden" id="postFileds" name="cardEntityVO.inputFileds"/>
					<dl style="width:700px">
						<dt><input type="checkbox" name="fileds" value="email" />会员Email</dt>
						<dt><input type="checkbox" name="fileds" value="qq" />会员QQ</dt>
						<dt><input type="checkbox" name="fileds" value="address" />会员联系地址</dt>
						<dt><input type="checkbox" name="fileds" value="idcard" />会员身份证号</dt>
						<dt><input type="checkbox" name="fileds" value="birthday" />会员出生日期</dt>
					</dl>
				<div class="divider"></div>
				<p style="width: 98%">
					<label>未激活图片：</label>
					<a class="button" onclick="openAddImgFrame(1);"><span>添加图片</span></a>
					<a id="add_pic_a_id1" class="btnAttach" href="<%=path%>/jsp/common/image_file_upload.jsp" lookupGroup="" width="560" height="300" style="display: none"></a>
					<div class="divider" style="border:0"></div>
					<div id="pic_need_add_pixel_div1"></div>
					<div class="divider" style="border:0"></div>
					<div id="pic_content_div1" style="float: none;width:auto;padding-left: 150px;"></div>
				</p>
				<div class="divider"></div>
				<p style="width: 98%">
					<label>已激活图片：</label>
					<a class="button" onclick="openAddImgFrame(2);"><span>添加图片</span></a>
					<a id="add_pic_a_id2" class="btnAttach" href="<%=path%>/jsp/common/image_file_upload.jsp" lookupGroup="" width="560" height="300" style="display: none"></a>
					<div class="divider" style="border:0"></div>
					<div id="pic_need_add_pixel_div2"></div>
					<div class="divider" style="border:0"></div>
					<div id="pic_content_div2" style="float: none;width:auto;padding-left: 150px;"></div>
				</p>
			</div>
			<div class="formBar">
				<ul>
					<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
					<li>
						<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
					</li>
				</ul>
			</div>
		</form>
	</div>
			<div>
				<p>请先创建会员卡</p>
			</div>
			
			<div>
				<p>请先创建会员卡</p>
			</div>
			
			<div>
				<p>请先创建会员卡</p>
			</div>
			
			<div>
				<p>请先创建会员卡</p>
			</div>
			<div>
				<p>请先创建会员卡</p>
			</div>
	</div>
	</div>
<script type="text/javascript">
var iu1 = new ImageUpload("","card","1","${pageContext.request.contextPath}","cardEntityVO.nonactivatedPic");
var iu2 = new ImageUpload("","card","2","${pageContext.request.contextPath}","cardEntityVO.activatedPic");
//initLevelAndAgio();
</script>
</div>